/**
 * Created by zhuhuijun on 2016/4/20
 */
/**
 * zhuhuijun
 * 页面用法：
 *  <ui-set var="title" expression="'hello world'"/>
 * 取值：
 * {{title}}->hello world
 * date:2016-4-20 15:44:32
 */
(function(window, angular, undefined) {
    'use strict';
    var directive = {};
    directive.uiSet = [function() {
        return {
            restrict : "EA",
            link : function(scope, elm, iAttrs) {
                scope.$watch(iAttrs.expression, function(val) {
                    scope[iAttrs.var] = val;
                    var apply = !scope.$$phase ? scope.$apply : angular.noop;
                    apply();
                });
            }
        };
    }];
    angular.module('app').directive(directive);
})(window, angular);